package org.travel_system.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.travel_system.pojo.EmergencyInformation;

import java.util.List;

@Mapper
public interface EmergencyMapper
{
    @Select("select * from emergency_information")
    List<EmergencyInformation> getEmergencies();

    @Select("select * from emergency_information where information_id = #{id}")
    EmergencyInformation getEmergencyById(int id);

    @Select("select * from emergency_information where is_approved = 1")
    List<EmergencyInformation> getEmergenciesApproved();

    @Insert("insert into emergency_information(title, content, publish_time, is_approved) values (#{title}, #{content}, #{publishTime}, #{isApproved})")
    int addEmergency(EmergencyInformation emergencyInformation);

    //审批
    @Update("update emergency_information set is_approved = 1 where information_id = #{id}")
    int approveEmergency(int id);
}
